package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateAppFunctionGetPageDTO;
import com.itlong.cloud.POJO.PO.AppFunctionInfoPO;
import com.itlong.cloud.POJO.VO.app.AppFunctionInfoVO;
import com.itlong.cloud.noncore.operate.IOperateAppFunctionInfoServiceClient;
import com.itlong.cloud.operate.service.IOperateAppFunctionInfoService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <desc>
 *      运营-APP-功能管理
 * </desc>
 *
 * @createDate 2017/09/29
 */
@RestController
public class OperateAppFunctionInfoServiceResource implements IOperateAppFunctionInfoServiceClient{
    @Autowired
    IOperateAppFunctionInfoService iOperateAppFunctionInfoService;

    /**
     * <desc>
     *      获取分页列表
     * </desc>
     *
     * @param operateAppFunctionGetPageDTO 分页查询参数DTO
     * @return 分页模型
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @RequestMapping(path = "/operate/appManage/function/getPage")
    @Override
    public Page<AppFunctionInfoPO> getPage(@RequestBody OperateAppFunctionGetPageDTO operateAppFunctionGetPageDTO) throws Exception {
        return iOperateAppFunctionInfoService.getPage(operateAppFunctionGetPageDTO);
    }

    /**
     * <desc>
     *      添加功能
     * </desc>
     *
     * @param appFunctionInfoPO 资源实体
     * @return sql执行行数
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @Override
    @RequestMapping(path = "/operate/appManage/function/save")
    public Integer save(@RequestBody AppFunctionInfoPO appFunctionInfoPO) throws Exception {
        return iOperateAppFunctionInfoService.save(appFunctionInfoPO);
    }

    /**
     * <desc>
     *      修改功能
     * </desc>
     *
     * @param appFunctionInfoPO 功能实体
     * @return sql执行行数
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @Override
    @RequestMapping(path = "/operate/appManage/function/update")
    public Integer update(@RequestBody AppFunctionInfoPO appFunctionInfoPO) throws Exception {
        return iOperateAppFunctionInfoService.update(appFunctionInfoPO);
    }

    /**
     * <desc>
     *      查询单条功能
     * </desc>
     *
     * @param appFunctionInfoPO 资源实体
     * @return 资源实体
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @Override
    @RequestMapping(path = "/operate/appManage/function/getOne")
    public AppFunctionInfoPO getOne(@RequestBody AppFunctionInfoPO appFunctionInfoPO) {
        return iOperateAppFunctionInfoService.getOne(appFunctionInfoPO);
    }


    /**
     * <desc>
     *      删除功能
     * </desc>
     *
     * @param appFunctionIds 资源id数组
     * @return 执行行数
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @Override
    @RequestMapping(path = "/operate/appManage/function/delete")
    public Integer delete(@RequestParam("appFunctionIds") String appFunctionIds) {
        return iOperateAppFunctionInfoService.delete(appFunctionIds);
    }

    /**
     * <desc>
     *      获取子节点
     * </desc>
     *
     * @param appFunctionId 功能id
     * @return 子级结果集
     * @author Jiaqi.X
     * @craeteDate 2017/09/21
     */
    @Override
    @RequestMapping(path = "/operate/appManage/function/getChilds")
    public List<AppFunctionInfoVO> getChilds(@RequestParam("appFunctionId")String appFunctionId) {
        return iOperateAppFunctionInfoService.getChilds(appFunctionId);
    }

    /**
     * <desc>
     *      获取分配功能所有节点
     * </desc>
     *
     * @return
     * @author Jiaqi.X
     * @createDate 2017/09/26
     */
    @Override
    @RequestMapping(path = "/operate/appManage/function/getAllotFunction")
    public List<AppFunctionInfoVO> getAllotFunction(@RequestParam("appPackageId") String appPackageId) {
        return iOperateAppFunctionInfoService.getAllotFunction(appPackageId);
    }

    /**
     * <desc>
     *      获取当前节点的父级节点以及同级别所有父级节点
     * </desc>
     *
     * @param parent 资源id
     * @return
     * @author Jiaqi.X
     * @createDate 2017/09/30
     */
    @Override
    @RequestMapping(path = "/operate/appManage/function/getParentLevelFunctions")
    public List<AppFunctionInfoPO> getParentLevelFunctions(@RequestParam("parent") String parent) {
        return iOperateAppFunctionInfoService.getParentLevelFunctions(parent);
    }

    /**
     * <desc>
     *      获取APP配置信息 供APP使用
     * </desc>
     *
     * @param projectId 项目id
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/02
     */
    @Override
    @RequestMapping(path = "/operate/appManage/function/getAppConfig")
    public List<AppFunctionInfoPO> getAppConfig(@RequestParam("projectId")String projectId){
        return iOperateAppFunctionInfoService.getAppConfig(projectId);
    }

    /**
     * <desc>
     *      云半径多场景项目上线后处理旧数据
     * </desc>
     *
     * @param
     * @return
     * @Author Zhu.yj
     * @createDate  2021/5/12
     */
    @PostMapping("/handlerOldPackage")
    @Override
    public Integer handlerOldPackage() {
        return iOperateAppFunctionInfoService.handlerOldPackage();
    }
}
